home *** CD-ROM | disk | FTP | other *** search
/ Champak 142 / Volume 142 Oct 17 2011 - Damaged.iso / Games / rapid-fire.swf / scripts / __Packages / Target.as < prev    next >
Text File  |  2011-10-17  |  7KB  |  196 lines

  1. class Target extends MovieClip
  2. {
  3.    function Target()
  4.    {
  5.       super();
  6.       this.Init();
  7.    }
  8.    function Init()
  9.    {
  10.       var _loc1_ = this;
  11.       var _loc2_ = _root;
  12.       switch(_loc1_.type)
  13.       {
  14.          case 1:
  15.             _loc1_.attachMovie("copter_mc","part",1,{_x:0,_y:-47});
  16.             _loc1_.dy = Math.random() >= 0.5 ? - (Math.random() * 1.5 + 1) : Math.random() * 1.5 + 1;
  17.             _loc1_.dx = Math.random() >= 0.5 ? - (Math.random() * 0.5 + 0.5) : Math.random() * 0.5 + 0.5;
  18.             _loc1_._x = Math.random() * 425;
  19.             _loc1_._y = _loc1_.dy <= 0 ? 442 : -32;
  20.             break;
  21.          case 2:
  22.             _loc1_.part = _loc1_.attachMovie("balloon_mc","part",1,{_x:-16,_y:-78});
  23.             _loc1_.part.hotspot.onPress = function()
  24.             {
  25.                var _loc1_ = this;
  26.                var _loc2_ = _root;
  27.                _loc1_._parent._parent._parent.attachMovie("balloon_pop_mc","b_pop_" + _loc2_.mc_counter,_loc2_.mc_counter,{color_index:_loc1_._parent._currentframe,_x:_loc1_._parent._parent._x - 16,_y:_loc1_._parent._parent._y - 78});
  28.                _loc2_.mc_counter += 1;
  29.                _loc1_._parent._parent.Fall();
  30.             };
  31.             _loc1_.sinus = 0;
  32.             _loc1_.dy = - (Math.random() * 1.5 + 1);
  33.             _loc1_.dx = Math.random() * 0.5 + 0.7;
  34.             _loc1_._x = Math.random() * 425;
  35.             _loc1_._y = 462;
  36.             break;
  37.          case 3:
  38.             _loc1_.part = _loc1_.attachMovie("spring_mc","part",1);
  39.             _loc1_.sinus = 0;
  40.             _loc1_.dx = Math.random() >= 0.5 ? - (Math.random() + 1) : Math.random() + 1;
  41.             _loc1_.dy = - (Math.random() * 1.5 + 1);
  42.             _loc1_.ay = 100 + Math.random() * 250;
  43.             _loc1_._x = _loc1_.dx <= 0 ? 505 : -80;
  44.             _loc1_._y = 442;
  45.             break;
  46.          case 4:
  47.             _loc1_.attachMovie("rubber_mc","part",1);
  48.             _loc1_._x = Math.random() * 425;
  49.             _loc1_._y = -40;
  50.             _loc1_.ay = Math.random() * 300 + 45;
  51.             break;
  52.          case 5:
  53.             _loc1_.part = _loc1_.attachMovie("wings_mc","part",1);
  54.             _loc1_.dx = Math.random() >= 0.5 ? - (Math.random() + 2) : Math.random() + 2;
  55.             _loc1_._x = _loc1_.dx <= 0 ? 515 : -90;
  56.             _loc1_.dy = Math.random() * 2 - 1;
  57.             _loc1_._y = Math.random() * 200 + 100;
  58.       }
  59.       _loc1_.hot_spot.onPress = function()
  60.       {
  61.          var _loc1_ = this;
  62.          var _loc2_ = _root;
  63.          _loc1_._parent.dx_shot = _loc2_._xmouse - _loc1_._parent._x - _loc2_.targets_holder_mc._x;
  64.          _loc1_._parent.dy_shot = _loc2_._ymouse - _loc1_._parent._y;
  65.          _loc1_._parent.Die();
  66.       };
  67.    }
  68.    function Update()
  69.    {
  70.       var _loc1_ = this;
  71.       switch(_loc1_.type)
  72.       {
  73.          case 1:
  74.             _loc1_._x += _loc1_.dx;
  75.             _loc1_._y += _loc1_.dy;
  76.             break;
  77.          case 2:
  78.             _loc1_._x += Math.sin(_loc1_.sinus) * _loc1_.dx;
  79.             _loc1_.sinus += 0.05;
  80.             _loc1_._y += _loc1_.dy;
  81.             break;
  82.          case 3:
  83.             _loc1_._x += _loc1_.dx;
  84.             _loc1_._y = 380 - Math.abs(Math.sin(_loc1_.sinus) * _loc1_.ay);
  85.             _loc1_.part._rotation = Math.sin(_loc1_.sinus * 2) * _loc1_.dx * 7;
  86.             _loc1_.sinus += 0.03;
  87.             if(_loc1_._x > 510 || _loc1_._x < -85)
  88.             {
  89.                _loc1_.removeMovieClip();
  90.             }
  91.             break;
  92.          case 4:
  93.             _loc1_.dy = _loc1_.ay - _loc1_._y;
  94.             _loc1_._y += _loc1_.dy / 10;
  95.             if(Math.abs(_loc1_._y - _loc1_.ay) < 0.5)
  96.             {
  97.                _loc1_.ay = -50;
  98.             }
  99.             break;
  100.          case 5:
  101.             _loc1_._x += _loc1_.dx;
  102.             _loc1_._y += _loc1_.dy;
  103.             _loc1_._y -= (_loc1_.part._currentframe - 11) / 10;
  104.             if(_loc1_._x > 520 || _loc1_._x < -95)
  105.             {
  106.                _loc1_.removeMovieClip();
  107.             }
  108.             break;
  109.          case 6:
  110.             _loc1_._y += _loc1_.dy;
  111.             _loc1_.dy += 0.3;
  112.       }
  113.       if(_loc1_.dy > 0)
  114.       {
  115.          if(_loc1_._y > 442)
  116.          {
  117.             _loc1_.removeMovieClip();
  118.          }
  119.       }
  120.       else if(_loc1_._y < -43)
  121.       {
  122.          _loc1_.removeMovieClip();
  123.       }
  124.    }
  125.    function Fall()
  126.    {
  127.       var _loc1_ = this;
  128.       _loc1_.part.removeMovieClip();
  129.       _loc1_.dy = 0;
  130.       _loc1_.type = 6;
  131.    }
  132.    function Die()
  133.    {
  134.       var _loc1_ = _root;
  135.       var _loc2_ = this;
  136.       if(_loc2_.type == 2)
  137.       {
  138.          _loc2_._parent.attachMovie("balloon_fly_mc","b_fly_" + _loc1_.mc_counter,_loc1_.mc_counter,{dx:_loc2_.dx,dy:_loc2_.dy,sinus:_loc2_.sinus,color_index:_loc2_.part._currentframe,_x:_loc2_._x - 16,_y:_loc2_._y - 78});
  139.          _loc1_.mc_counter += 1;
  140.       }
  141.       var shot_radius = Math.sqrt(_loc2_.dx_shot * _loc2_.dx_shot + _loc2_.dy_shot * _loc2_.dy_shot);
  142.       if(shot_radius <= 3)
  143.       {
  144.          _loc1_.bulls_eye_snd.start(0,1);
  145.          _loc1_.perfect_combo += 1;
  146.          var points = 20 * _loc1_.perfect_combo;
  147.       }
  148.       else
  149.       {
  150.          _loc1_.perfect_combo = 0;
  151.          var points = Math.floor((1 - (shot_radius - 3) / 23) * 19) + 1;
  152.       }
  153.       _loc1_.score += points;
  154.       _loc1_.goal -= points;
  155.       _loc1_.goal = _loc1_.goal >= 0 ? _loc1_.goal : 0;
  156.       if(_loc1_.goal == 0 && !_loc1_.level_win)
  157.       {
  158.          _loc1_.got_goal_snd.start(0,1);
  159.          var _loc3_ = 0;
  160.          while(_loc3_ < 6)
  161.          {
  162.             _loc1_["goal_num_" + _loc3_]._visible = false;
  163.             _loc3_ = _loc3_ + 1;
  164.          }
  165.          _loc1_.attachMovie("got_goal_mc","got_goal_mc",_loc1_.mc_counter,{_x:491,_y:304});
  166.          _loc1_.mc_counter += 1;
  167.          _loc1_.level_win = true;
  168.       }
  169.       _loc1_.ShowScore();
  170.       var t_shot = _loc2_._parent.attachMovie("target_shot_mc","t_shot_" + _loc1_.mc_counter,_loc1_.mc_counter - 5000,{_x:_loc2_._x,_y:_loc2_._y});
  171.       _loc1_.mc_counter += 1;
  172.       switch(_loc2_.type)
  173.       {
  174.          case 1:
  175.          case 3:
  176.             _loc2_._parent.attachMovie("debris_mc","debris_" + _loc1_.mc_counter,_loc1_.mc_counter,{type:_loc2_.type,x:_loc2_._x,y:_loc2_._y,r:_loc2_.part._rotation});
  177.             _loc1_.mc_counter += 1;
  178.             break;
  179.          case 4:
  180.             _loc2_._parent.attachMovie("rubber_band","r_band_" + _loc1_.mc_counter,_loc1_.mc_counter,{_x:_loc2_._x,_y:_loc2_._y});
  181.             _loc1_.mc_counter += 1;
  182.             break;
  183.          case 5:
  184.             _loc2_._parent.attachMovie("debris_mc","debris_" + _loc1_.mc_counter,_loc1_.mc_counter,{type:5,x:_loc2_._x,y:_loc2_._y});
  185.             _loc1_.mc_counter += 1;
  186.             _loc2_._parent.attachMovie("debris_mc","debris_" + _loc1_.mc_counter,_loc1_.mc_counter,{type:6,x:_loc2_._x,y:_loc2_._y});
  187.             _loc1_.mc_counter += 1;
  188.       }
  189.       t_shot.shot_dot._x = _loc2_.dx_shot;
  190.       t_shot.shot_dot._y = _loc2_.dy_shot;
  191.       _loc2_._parent.attachMovie("points_mc","pts_" + _loc1_.mc_counter,_loc1_.mc_counter,{_x:_loc2_._x,_y:_loc2_._y - 36,points:points});
  192.       _loc1_.mc_counter += 1;
  193.       _loc2_.removeMovieClip();
  194.    }
  195. }
  196.